﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Package;
using Microsoft.VisualStudio.TextManager.Interop;

namespace NBusiness.VisualStudio
{
    public class ESharpColorizer : Colorizer
    {
        IVsTextLines _buffer;
        internal IVsTextLines Buffer
        {
            get { return _buffer; }
        }

        public ESharpColorizer(LanguageService service, IVsTextLines buffer, IScanner scanner)
            : base(service, buffer, scanner)
        {
            _buffer = buffer;
        }

        public override int ColorizeLine(int line, int length, IntPtr ptr, int state, uint[] attrs)
        {
            (this.Scanner as ESharpScanner).SetLine(line);
            return base.ColorizeLine(line, length, ptr, state, attrs);
        }

        public override void CloseColorizer()
        {
            base.CloseColorizer();
            OnClosed();
        }

        public event EventHandler Closed;
        protected void OnClosed()
        {
            if (Closed != null) Closed(this, EventArgs.Empty);
        }
    }
}
